; Disassembly of the file "BDOS.bin"
;
; CPU Type: Z80
;
; Created with dZ80 2.0
;
; on Saturday, 13 of July 2013 at 04:45 PM
;
D100 F9        DEFB    $F9		; ###### BDOS saving start point
D101 16        DEFB    $16	; this is not
D102 00        DEFB    $00	; part of BDOS,
D103 00        DEFB    $00	; but was saved
D104 00        DEFB    $00	; so we can begin
D105 1A        DEFB    $1A	; from a round address
;
;	MAIN BDOS ENTRY POINT.
;	ALL CALL ARE ROUTED THROUGH HERE BY
;	VECTOR LOCATED AT 0005H
;

D106 C311D1    JP      $D111		; ###### BDOS ENTRY POINT ######
					; (JUMP OVER ERROR VECTORS TO START)
;
;	ERROR HANDLER VECTORS
;
D109 99D1      DEFW    $D199	; <BAD   SECTOR  ERROR>=D199
D10B A5D1      DEFW    $D1A5	; <DISK  SELECT  ERROR>=D1A5
D10D ABD1      DEFW    $D1AB	; <DISK READ ONLY ERROR>=D1AB
D10F B1D1      DEFW    $D1B1	; <FILE READ ONLY ERROR>=D1B1
;
;	STARTING POINT OF BASIC DISK OPERATING SYSTEM
;
D111 EB        EX      DE,HL		; ###### actual entry point
D112 2243D4    LD      ($D443),HL ; save function argument from DE into (D443)
D115 EB        EX      DE,HL
D116 7B        LD      A,E	  ; lower byte of argument from DE...
D117 32D6DE    LD      ($DED6),A  ; ...saved into (DED6)
D11A 210000    LD      HL,$0000
D11D 2245D4    LD      ($D445),HL ; ZERO OUT RETURN PARAMETER
D120 39        ADD     HL,SP
D121 220FD4    LD      ($D40F),HL ; SAVE CALLING PROGRAM STACK POINTER in (D40F)
D124 3141D4    LD      SP,$D441	  ; SET UP BDOS STACK at D441
D127 AF        XOR     A
D128 32E0DE    LD      ($DEE0),A  ; ZERO OUT DISK NUMBER (DISKNO)
D12B 32DEDE    LD      ($DEDE),A  ; ZERO OUT DISK SETUP FLAG (SETUPF)
D12E 2174DE    LD      HL,$DE74	  ; BDOS EXIT POINT ADDRESS
D131 E5        PUSH    HL	  ; PUT EXIT POINT ADDRESS UP FOR USE WHEN COMMAND IS COMPLETED
D132 79        LD      A,C	  ; A = BDOS function number
D133 FE29      CP      $29	  ; CHECK FOR VALID COMMAND NUMBER
D135 D0        RET     NC	  ; NO GOOD - THERE ARE ONLY 40 COMMANDS (28h=40)

D136 4B        LD      C,E	  ; lower byte of argument from DE
D137 2147D1    LD      HL,$D147   ; START ADDR OF COMMAND VECTOR TABLE (COMTAB)
D13A 5F        LD      E,A	  ; E = BDOS function number
D13B 1600      LD      D,$00
D13D 19        ADD     HL,DE
D13E 19        ADD     HL,DE	  ; HL = D147 + (2 * BDOS function number) [POINT TO COMMAND VECTOR]
D13F 5E        LD      E,(HL)
D140 23        INC     HL
D141 56        LD      D,(HL)	  ; DE = (HL)	--> MOVE COMMAND VECTOR INTO (DE)
D142 2A43D4    LD      HL,($D443) ; GET BACK ORIGINAL ENTRY CONTENTS OF (DE)
D145 EB        EX      DE,HL
D146 E9        JP      (HL)	  ; jump to address found at (D147 + (2 * BDOS function number))
				  ; BDOS routine numbers 00 to 28 means 29h routines in total.
				  ; Next are 29h*2=52h bytes of data (jump addresses)
;
;	BDOS COMMAND VECTOR TABLE
;
;	Contains vectors for 40 commands, including two
;	reserved spaces for future commands, and two
;	undocumented commands.
;
D147 03DF	DEFW	$DF03 ; BDOS function #00 (System Reset)		= DF03
D149 C8D3	DEFW	$D3C8 ; BDOS function #01 (Console Input)		= D3C8
D14B 90D2	DEFW	$D290 ; BDOS function #02 (Console Output)		= D290
D14D CED3	DEFW	$D3CE ; BDOS function #03 (Reader Input)		= D3CE
D14F 12DF	DEFW	$DF12 ; BDOS function #04 (Punch Output)		= DF12
D151 0FDF	DEFW	$DF0F ; BDOS function #05 (List Output)			= DF0F
D153 D4D3	DEFW	$D3D4 ; BDOS function #06 (Direct Console I/O)		= D3D4
D155 EDD3	DEFW	$D3ED ; BDOS function #07 (Get I/O Byte)		= D3ED
D157 F3D3	DEFW	$D3F3 ; BDOS function #08 (Set I/O Byte)		= D3F3
D159 F8D3	DEFW	$D3F8 ; BDOS function #09 (Print String)		= D3F8
D15B E1D2	DEFW	$D2E1 ; BDOS function #0A (Read Console Buffer)		= D2E1
D15D FED3	DEFW	$D3FE ; BDOS function #0B (Get Console Status)		= D3FE
D15F 7EDD	DEFW	$DD7E ; BDOS function #0C (Return Version Number)	= DD7E
D161 83DD	DEFW	$DD83 ; BDOS function #0D (Reset Disk System)		= DD83
D163 45DD	DEFW	$DD45 ; BDOS function #0E (Select Disk)			= DD45
D165 9CDD	DEFW	$DD9C ; BDOS function #0F (Open File)			= DD9C
D167 A5DD	DEFW	$DDA5 ; BDOS function #10 (Close File)			= DDA5
D169 ABDD	DEFW	$DDAB ; BDOS function #11 (Search for First)		= DDAB
D16B C8DD	DEFW	$DDC8 ; BDOS function #12 (Search for Next)		= DDC8
D16D D7DD	DEFW	$DDD7 ; BDOS function #13 (Delete File)			= DDD7
D16F E0DD	DEFW	$DDE0 ; BDOS function #14 (Read Sequential)		= DDE0
D171 E6DD	DEFW	$DDE6 ; BDOS function #15 (Write Sequential)		= DDE6
D173 ECDD	DEFW	$DDEC ; BDOS function #16 (Make File)			= DDEC
D175 F5DD	DEFW	$DDF5 ; BDOS function #17 (Rename File)			= DDF5
D177 FEDD	DEFW	$DDFE ; BDOS function #18 (Return Log-In Vector)	= DDFE
D179 04DE	DEFW	$DE04 ; BDOS function #19 (Return Current Disk)		= DE04
D17B 0ADE	DEFW	$DE0A ; BDOS function #1A (Set DMA Address)		= DE0A
D17D 11DE	DEFW	$DE11 ; BDOS function #1B (Get ADDR (Alloc))		= DE11
D17F 2CD6	DEFW	$D62C ; BDOS function #1C (Write Protect Disk)		= D62C
D181 17DE	DEFW	$DE17 ; BDOS function #1D (Get Read/Only Vector)	= DE17
D183 1DDE	DEFW	$DE1D ; BDOS function #1E (Set File Attributes)		= DE1D
D185 26DE	DEFW	$DE26 ; BDOS function #1F (Get ADDR (Disk Parms))	= DE26
D187 2DDE	DEFW	$DE2D ; BDOS function #20 (Set/Get User Code)		= DE2D
D189 41DE	DEFW	$DE41 ; BDOS function #21 (Read Random)			= DE41
D18B 47DE	DEFW	$DE47 ; BDOS function #22 (Write Random)		= DE47
D18D 4DDE	DEFW	$DE4D ; BDOS function #23 (Compute File Size)		= DE4D
D18F 0EDD	DEFW	$DD0E ; BDOS function #24 (Set Random Record)		= DD0E
D191 53DE	DEFW	$DE53 ; BDOS function #25 (Reset Drive)			= DE53
D193 04D4	DEFW	$D404 ; BDOS function #26 (NOT USED)			= D404
D195 04D4	DEFW	$D404 ; BDOS function #27 (NOT USED)			= D404
D197 9BDE	DEFW	$DE9B ; BDOS function #28 (Write Random With Zero Fill)	= DE9B
;
;	BDOS ERROR HANDLING ROUTINES
;
D199 21CAD1	LD	HL,$D1CA	; <BAD SECTOR ERROR>
D19C CDE5D1	CALL	$D1E5		; CALL ERRMSG
D19F FE03	CP	$03		; CHECK FOR A CONTROL C
D1A1 CA0000	JP	Z,$0000		; Jump to REBOOT if CONTROL C
D1A4 C9		RET

;	NOTE:	There should be some change made to this
;		piece of code because when you have tried
;		to select a non-existent drive, you will
;		reboot and immediately try to select that
;		drive. This gives an error message and a
;		reboot which reselects the drive........

D1A5 21D5D1	LD	HL,$D1D5	; <DISK SELECT ERROR>
D1A8 C3B4D1	JP	$D1B4		; Jump to ROERR2
D1AB 21E1D1	LD	HL,$D1E1	; <DISK READ ONLY ERROR>
D1AE C3B4D1	JP	$D1B4		; Jump to ROERR2
D1B1 21DCD1	LD	HL,$D1DC	; <FILE READ ONLY ERROR>
D1B4 CDE5D1	CALL	$D1E5		; call ERRMSG
D1B7 C30000	JP	$0000		; jump to REBOOT
;
;	ERROR MESSAGE STRINGS
;
D1BA 42        DEFB    $42	; B
D1BB 64        DEFB    $64	; d
D1BC 6F        DEFB    $6F	; o
D1BD 73        DEFB    $73	; s
D1BE 20        DEFB    $20	;
D1BF 45        DEFB    $45	; E
D1C0 72        DEFB    $72	; r
D1C1 72        DEFB    $72	; r
D1C2 20        DEFB    $20	;
D1C3 4F        DEFB    $4F	; O
D1C4 6E        DEFB    $6E	; n
D1C5 20        DEFB    $20	;
D1C6 20        DEFB    $20	;
D1C7 3A        DEFB    $3A	; :
D1C8 20        DEFB    $20	;
D1C9 24        DEFB    $24	; $
D1CA 42        DEFB    $42	; B
D1CB 61        DEFB    $61	; a
D1CC 64        DEFB    $64	; d
D1CD 20        DEFB    $20	;
D1CE 53        DEFB    $53	; S
D1CF 65        DEFB    $65	; e
D1D0 63        DEFB    $63	; c
D1D1 74        DEFB    $74	; t
D1D2 6F        DEFB    $6F	; o
D1D3 72        DEFB    $72	; r
D1D4 24        DEFB    $24	; $
D1D5 53        DEFB    $53	; S
D1D6 65        DEFB    $65	; e
D1D7 6C        DEFB    $6C	; l
D1D8 65        DEFB    $65	; e
D1D9 63        DEFB    $63	; c
D1DA 74        DEFB    $74	; t
D1DB 24        DEFB    $24	; $
D1DC 46        DEFB    $46	; F
D1DD 69        DEFB    $69	; i
D1DE 6C        DEFB    $6C	; l
D1DF 65        DEFB    $65	; e
D1E0 20        DEFB    $20	;
D1E1 52        DEFB    $52	; R
D1E2 2F        DEFB    $2F	; /
D1E3 4F        DEFB    $4F	; O
D1E4 24        DEFB    $24	; $
;
;	PRINT OUT THE ERROR MESSAGE
;
D1E5 E5		PUSH	HL		; SAVE THE POINTER
D1E6 CDC9D2	CALL	$D2C9		; START A NEW LINE (call PCRLF)
D1E9 3A42D4	LD	A,($D442)	; GET THE CURRENT DISK NUMBER (CURDSK)
D1EC C641	ADD	A,$41		; ADD THE ASCII BIAS+1
D1EE 32C6D1	LD	($D1C6),A	; put the correct drive letter in err message
D1F1 01BAD1	LD	BC,$D1BA	; POINT TO ERROR MESSAGE
D1F4 CDD3D2	CALL	$D2D3		; PRINT ERROR MESSAGE STRING (call PRNSTR)
D1F7 C1		POP	BC		; GET BACK ORIGINAL POINTER
D1F8 CDD3D2	CALL	$D2D3		; AND PRINT THAT STRING TOO (call PRNSTR)

;	CONSOLE KEYBOARD INPUT

D1FB 210ED4	LD	HL,$D40E	; SWAP THE CONTENTS OF THE KEYBOARD FLAG BYTE...
D1FE 7E		LD	A,(HL)
D1FF 3600	LD	(HL),$00	; ...WITH A 00
D201 B7		OR	A
D202 C0		RET	NZ		; RETURN IF SOMETHING ALREADY THERE
D203 C309DF	JP	$DF09		; ELSE GET SOMETHING VIA A BIOS CALL TO CONSOLE INPUT (jump to CONIN)

D206 CDFBD1	CALL	$D1FB		; GET A CHARACTER FROM KEYBOARD (call INPUT)
D209 CD14D2	CALL	$D214		; CHECK TO SEE IF IS A CONTROL CHARACTER (call SETFLG)
D20C D8		RET	C		; RETURN IF IT IS
D20D F5		PUSH	AF		; ELSE ECHO IT TO THE CONSOLE
D20E 4F		LD	C,A		; (AND PERHAPS THE LIST DEVICE)
D20F CD90D2	CALL	$D290		; CONSOLE OUTPUT (call BDOS#02)
D212 F1		POP	AF
D213 C9		RET

D214 FE0D      CP      $0D
D216 C8        RET     Z

D217 FE0A      CP      $0A
D219 C8        RET     Z

D21A FE09      CP      $09
D21C C8        RET     Z

D21D FE08      CP      $08
D21F C8        RET     Z

D220 FE20      CP      $20
D222 C9        RET

D223 3A0ED4    LD      A,($D40E)
D226 B7        OR      A
D227 C245D2    JP      NZ,$D245
D22A CD06DF    CALL    $DF06
D22D E601      AND     $01
D22F C8        RET     Z

D230 CD09DF    CALL    $DF09
D233 FE13      CP      $13
D235 C242D2    JP      NZ,$D242
D238 CD09DF    CALL    $DF09
D23B FE03      CP      $03
D23D CA0000    JP      Z,$0000
D240 AF        XOR     A
D241 C9        RET

D242 320ED4    LD      ($D40E),A
D245 3E01      LD      A,$01
D247 C9        RET

D248 3A0AD4    LD      A,($D40A)
D24B B7        OR      A
D24C C262D2    JP      NZ,$D262
D24F C5        PUSH    BC
D250 CD23D2    CALL    $D223
D253 C1        POP     BC
D254 C5        PUSH    BC
D255 CD0CDF    CALL    $DF0C
D258 C1        POP     BC
D259 C5        PUSH    BC
D25A 3A0DD4    LD      A,($D40D)
D25D B7        OR      A
D25E C40FDF    CALL    NZ,$DF0F
D261 C1        POP     BC
D262 79        LD      A,C
D263 210CD4    LD      HL,$D40C
D266 FE7F      CP      $7F
D268 C8        RET     Z

D269 34        INC     (HL)
D26A FE20      CP      $20
D26C D0        RET     NC

D26D 35        DEC     (HL)
D26E 7E        LD      A,(HL)
D26F B7        OR      A
D270 C8        RET     Z

D271 79        LD      A,C
D272 FE08      CP      $08
D274 C279D2    JP      NZ,$D279
D277 35        DEC     (HL)
D278 C9        RET

D279 FE0A      CP      $0A
D27B C0        RET     NZ

D27C 3600      LD      (HL),$00
D27E C9        RET

D27F 79        LD      A,C
D280 CD14D2    CALL    $D214
D283 D290D2    JP      NC,$D290
D286 F5        PUSH    AF
D287 0E5E      LD      C,$5E
D289 CD48D2    CALL    $D248
D28C F1        POP     AF
D28D F640      OR      $40
D28F 4F        LD      C,A
D290 79        LD      A,C
D291 FE09      CP      $09
D293 C248D2    JP      NZ,$D248
D296 0E20      LD      C,$20
D298 CD48D2    CALL    $D248
D29B 3A0CD4    LD      A,($D40C)
D29E E607      AND     $07
D2A0 C296D2    JP      NZ,$D296
D2A3 C9        RET

D2A4 CDACD2    CALL    $D2AC
D2A7 0E20      LD      C,$20
D2A9 CD0CDF    CALL    $DF0C
D2AC 0E08      LD      C,$08
D2AE C30CDF    JP      $DF0C
D2B1 0E23      LD      C,$23
D2B3 CD48D2    CALL    $D248
D2B6 CDC9D2    CALL    $D2C9
D2B9 3A0CD4    LD      A,($D40C)
D2BC 210BD4    LD      HL,$D40B
D2BF BE        CP      (HL)
D2C0 D0        RET     NC

D2C1 0E20      LD      C,$20
D2C3 CD48D2    CALL    $D248
D2C6 C3B9D2    JP      $D2B9
D2C9 0E0D      LD      C,$0D
D2CB CD48D2    CALL    $D248
D2CE 0E0A      LD      C,$0A
D2D0 C348D2    JP      $D248
D2D3 0A        LD      A,(BC)
D2D4 FE24      CP      $24
D2D6 C8        RET     Z

D2D7 03        INC     BC
D2D8 C5        PUSH    BC
D2D9 4F        LD      C,A
D2DA CD90D2    CALL    $D290
D2DD C1        POP     BC
D2DE C3D3D2    JP      $D2D3
D2E1 3A0CD4    LD      A,($D40C)
D2E4 320BD4    LD      ($D40B),A
D2E7 2A43D4    LD      HL,($D443)
D2EA 4E        LD      C,(HL)
D2EB 23        INC     HL
D2EC E5        PUSH    HL
D2ED 0600      LD      B,$00
D2EF C5        PUSH    BC
D2F0 E5        PUSH    HL
D2F1 CDFBD1    CALL    $D1FB
D2F4 E67F      AND     $7F
D2F6 E1        POP     HL
D2F7 C1        POP     BC
D2F8 FE0D      CP      $0D
D2FA CAC1D3    JP      Z,$D3C1
D2FD FE0A      CP      $0A
D2FF CAC1D3    JP      Z,$D3C1
D302 FE08      CP      $08
D304 C216D3    JP      NZ,$D316
D307 78        LD      A,B
D308 B7        OR      A
D309 CAEFD2    JP      Z,$D2EF
D30C 05        DEC     B
D30D 3A0CD4    LD      A,($D40C)
D310 320AD4    LD      ($D40A),A
D313 C370D3    JP      $D370
D316 FE7F      CP      $7F
D318 C226D3    JP      NZ,$D326
D31B 78        LD      A,B
D31C B7        OR      A
D31D CAEFD2    JP      Z,$D2EF
D320 7E        LD      A,(HL)
D321 05        DEC     B
D322 2B        DEC     HL
D323 C3A9D3    JP      $D3A9
D326 FE05      CP      $05
D328 C237D3    JP      NZ,$D337
D32B C5        PUSH    BC
D32C E5        PUSH    HL
D32D CDC9D2    CALL    $D2C9
D330 AF        XOR     A
D331 320BD4    LD      ($D40B),A
D334 C3F1D2    JP      $D2F1
D337 FE10      CP      $10
D339 C248D3    JP      NZ,$D348
D33C E5        PUSH    HL
D33D 210DD4    LD      HL,$D40D
D340 3E01      LD      A,$01
D342 96        SUB     (HL)
D343 77        LD      (HL),A
D344 E1        POP     HL
D345 C3EFD2    JP      $D2EF
D348 FE18      CP      $18
D34A C25FD3    JP      NZ,$D35F
D34D E1        POP     HL
D34E 3A0BD4    LD      A,($D40B)
D351 210CD4    LD      HL,$D40C
D354 BE        CP      (HL)
D355 D2E1D2    JP      NC,$D2E1
D358 35        DEC     (HL)
D359 CDA4D2    CALL    $D2A4
D35C C34ED3    JP      $D34E
D35F FE15      CP      $15
D361 C26BD3    JP      NZ,$D36B
D364 CDB1D2    CALL    $D2B1
D367 E1        POP     HL
D368 C3E1D2    JP      $D2E1
D36B FE12      CP      $12
D36D C2A6D3    JP      NZ,$D3A6
D370 C5        PUSH    BC
D371 CDB1D2    CALL    $D2B1
D374 C1        POP     BC
D375 E1        POP     HL
D376 E5        PUSH    HL
D377 C5        PUSH    BC
D378 78        LD      A,B
D379 B7        OR      A
D37A CA8AD3    JP      Z,$D38A
D37D 23        INC     HL
D37E 4E        LD      C,(HL)
D37F 05        DEC     B
D380 C5        PUSH    BC
D381 E5        PUSH    HL
D382 CD7FD2    CALL    $D27F
D385 E1        POP     HL
D386 C1        POP     BC
D387 C378D3    JP      $D378
D38A E5        PUSH    HL
D38B 3A0AD4    LD      A,($D40A)
D38E B7        OR      A
D38F CAF1D2    JP      Z,$D2F1
D392 210CD4    LD      HL,$D40C
D395 96        SUB     (HL)
D396 320AD4    LD      ($D40A),A
D399 CDA4D2    CALL    $D2A4
D39C 210AD4    LD      HL,$D40A
D39F 35        DEC     (HL)
D3A0 C299D3    JP      NZ,$D399
D3A3 C3F1D2    JP      $D2F1
D3A6 23        INC     HL
D3A7 77        LD      (HL),A
D3A8 04        INC     B
D3A9 C5        PUSH    BC
D3AA E5        PUSH    HL
D3AB 4F        LD      C,A
D3AC CD7FD2    CALL    $D27F
D3AF E1        POP     HL
D3B0 C1        POP     BC
D3B1 7E        LD      A,(HL)
D3B2 FE03      CP      $03
D3B4 78        LD      A,B
D3B5 C2BDD3    JP      NZ,$D3BD
D3B8 FE01      CP      $01
D3BA CA0000    JP      Z,$0000
D3BD B9        CP      C
D3BE DAEFD2    JP      C,$D2EF
D3C1 E1        POP     HL
D3C2 70        LD      (HL),B
D3C3 0E0D      LD      C,$0D
D3C5 C348D2    JP      $D248
D3C8 CD06D2    CALL    $D206
D3CB C301D4    JP      $D401
D3CE CD15DF    CALL    $DF15
D3D1 C301D4    JP      $D401
D3D4 79        LD      A,C
D3D5 3C        INC     A
D3D6 CAE0D3    JP      Z,$D3E0
D3D9 3C        INC     A
D3DA CA06DF    JP      Z,$DF06
D3DD C30CDF    JP      $DF0C
D3E0 CD06DF    CALL    $DF06
D3E3 B7        OR      A
D3E4 CA91DE    JP      Z,$DE91
D3E7 CD09DF    CALL    $DF09
D3EA C301D4    JP      $D401
D3ED 3A0300    LD      A,($0003)
D3F0 C301D4    JP      $D401
D3F3 210300    LD      HL,$0003
D3F6 71        LD      (HL),C
D3F7 C9        RET

D3F8 EB        EX      DE,HL
D3F9 4D        LD      C,L
D3FA 44        LD      B,H
D3FB C3D3D2    JP      $D2D3
D3FE CD23D2    CALL    $D223
D401 3245D4    LD      ($D445),A
D404 C9        RET

D405 3E01      LD      A,$01
D407 C301D4    JP      $D401

D40A 00        DEFB    $00	; CHARACTER COUNTER #1, USED IN READ CONSOLE BUFFER
D40B 00        DEFB    $00	; CHARACTER COUNTER #2, USED IN READ CONSOLE BUFFER
D40C 00        DEFB    $00	; OUTPUT LINE CHARACTER COUNTER, USED TO KEEP COUNT FOR TAB CHARACTER
D40D 00        DEFB    $00	; LIST DEVICE FLAG. WHEN <> 00 OUTPUT GOES TO LIST DEVICE
D40E 00        DEFB    $00	; KEYBOARD STATUS FLAG. IF <> 0 THEN CHARACTER IS AVAILABLE
D40F 00        DEFW    $0000	; CALLING PROGRAM STACK POINTER
D411 00        DEFB    $00	; ########## BDOS STACK AREA START ##########
D412 00        DEFB    $00	;			...
D413 00        DEFB    $00	;
D414 00        DEFB    $00	;			...
D415 00        DEFB    $00	;
D416 00        DEFB    $00	;			...
D417 00        DEFB    $00	;
D418 00        DEFB    $00	;			...
D419 00        DEFB    $00	;
D41A 00        DEFB    $00	;			...
D41B 00        DEFB    $00	;
D41C 00        DEFB    $00	;			...
D41D 00        DEFB    $00	;
D41E 00        DEFB    $00	;			...
D41F 00        DEFB    $00	;
D420 00        DEFB    $00	;			...
D421 00        DEFB    $00	;
D422 00        DEFB    $00	;			...
D423 00        DEFB    $00	;
D424 00        DEFB    $00	;			...
D425 00        DEFB    $00	;
D426 00        DEFB    $00	;			...
D427 00        DEFB    $00	;
D428 00        DEFB    $00	;			... 30h=48 bytes in total
D429 00        DEFB    $00	;
D42A 00        DEFB    $00	;			...
D42B 00        DEFB    $00	;
D42C 00        DEFB    $00	;			...
D42D 00        DEFB    $00	;
D42E 00        DEFB    $00	;			...
D42F 00        DEFB    $00	;
D430 00        DEFB    $00	;			...
D431 00        DEFB    $00	;
D432 00        DEFB    $00	;			...
D433 00        DEFB    $00	;
D434 00        DEFB    $00	;			...
D435 00        DEFB    $00	;
D436 00        DEFB    $00	;			...
D437 00        DEFB    $00	;
D438 00        DEFB    $00	;			...
D439 00        DEFB    $00	;
D43A 00        DEFB    $00	;			...
D43B 00        DEFB    $00	;
D43C 00        DEFB    $00	;			...
D43D 00        DEFB    $00	;
D43E 00        DEFB    $00	;			...
D43F 00        DEFB    $00	;
D440 00        DEFB    $00	; ########## BDOS STACK AREA END ##########
D441 00        DEFB    $00	; USERNO (CURRENT USER NUMBER STORAGE)		<--- BDOS STACK
D442 00        DEFB    $00	; CURDSK (CURRENT DISK NUMBER)
D443 00        DEFW    $0000	; BDOS FUNCTION PARAMETER FROM DE
D445 00        DEFW    $0000	; BDOS RETURN PARAMETER
;
;	ERROR HANDLING ROUTINES
;
;	NOTE:
;		Again we see that convoluted nature of this
;		program. Why don't the error calls from the
;		program just jump to the code just following
;		command table instead of this intermediate 
;		step of picking up an indirect jump vector?
;
D447 210BD1    LD      HL,$D10B	; DISK SELECT ERROR
D44A 5E        LD      E,(HL)
D44B 23        INC     HL
D44C 56        LD      D,(HL)	; load vector in DE
D44D EB        EX      DE,HL	; swap it to HL
D44E E9        JP      (HL)	; jump to DISK SELECT ERROR routine
;
;	BLOCK MOVE SUBROUTINE
;
;	ENTRY PARAMETERS:
;		(HL)	DESTINATION
;		(DE)	SOURCE
;		(C)	BYTE COUNT
;
;	NOTE:
;		Z80 users may want to eliminate this and
;		use LDIR with a suitable swapping of the
;		HL and DE register pairs & using (BC)
;		of just (C) as the counter.
;
D44F 0C        INC     C
D450 0D        DEC     C
D451 C8        RET     Z

D452 1A        LD      A,(DE)
D453 77        LD      (HL),A
D454 13        INC     DE
D455 23        INC     HL
D456 C350D4    JP      $D450
;
;	SET UP DISK PARAMETERS WHEN LOGGIN IN A NEW DISK
;
;	THE VARIOUS PARAMETERS FROM BIOS ARE MOVE TO
;	WHERE BDOS CAN USED THEM. THE LOCATION  OF THE
;	DISK SIZE, DIRECTORY TRACK ETC. ARE MOVED TO
;	A PARAMETER BLOCK AT THE END OF BDOS.
;
;	NOTE:
;		1.  If the program involves much action
;		between disk drives, considerable time
;		can be wasted in this swapping process.
;		This may be an area where improvemnts
;		can be made.
;
;		2.  If the disk is not a single sided,
;		double density 5 1/4" or a single density
;		8", and can thus hold more than 255K, then
;		the block numbers must be double precision
;		and will occupy 2 bytes. Consequently a
;		single directory extent can only hold 8
;		block numbers, and therefore 8K if 1K
;		blocks are used. In order to get enough
;		directory space either the number of
;		directory entries must be increased, or
;		the block size increased to 2K. For
;		more details on this read the Digital
;		Research documentation (and you will
;		get thoroughly confused).

				; ######### SETDSK (set disk params) #########
D459 3A42D4    LD      A,($D442) ; GET THE NUMBER OF THE DISK
D45C 4F        LD      C,A
D45D CD1BDF    CALL    $DF1B	; call BIOS SELDSK function
D460 7C        LD      A,H	; if SELDSK returns (HL)=0000
D461 B5        OR      L	; you are trying to access
D462 C8        RET     Z	; a nonexistent drive; error return with HL=0000.
				; otherwise return DPH start addr in HL
D463 5E        LD      E,(HL)
D464 23        INC     HL
D465 56        LD      D,(HL)	; DE = XLT base addr
D466 23        INC     HL
D467 22B3DE    LD      ($DEB3),HL ; (DEB3)=DWORD1 low byte
D46A 23        INC     HL
D46B 23        INC     HL
D46C 22B5DE    LD      ($DEB5),HL ; (DEB5)=DWORD2 low byte
D46F 23        INC     HL
D470 23        INC     HL
D471 22B7DE    LD      ($DEB7),HL ; (DEB7)=DWORD3 low byte
D474 23        INC     HL
D475 23        INC     HL
D476 EB        EX      DE,HL	  ; HL = XLT base addr, DE = DIRBUF low byte addr in BIOS DPH
D477 22D0DE    LD      ($DED0),HL ; (DED0) = XLT base addr
;	
;	(DE) NOW POINTS TO DIRBUF IN PARAMETER TABLE.
;	THE FOLLOWING ARE NOW MOVED INTO BDOS PARAMETER AREA:
;
;	(DIRBUF)	POINTER TO DIRECTORY BUFFER
;	(DPBLK)		POINTER TO DISK PARAMETER BLOCK
;	(CHKxx)		POINTER TO DIRECTORY CHECKSUM BLOCK
;	(ALLxx)		POINTER TO ALLOCATION BLOCK MAP
;
D47A 21B9DE    LD      HL,$DEB9	; directory buffer pointer address
D47D 0E08      LD      C,$08
D47F CD4FD4    CALL    $D44F	; BLOCK MOVE subroutine, DIRBUF, DPB, CSV, ALV copied from BIOS DPH into BDOS parm area
D482 2ABBDE    LD      HL,($DEBB) ; pointer to DPB in BIOS
D485 EB        EX      DE,HL	; stored in DE
D486 21C1DE    LD      HL,$DEC1	; start of DPB in BDOS
D489 0E0F      LD      C,$0F	; 15 bytes to copy
D48B CD4FD4    CALL    $D44F	; from DPB in BIOS to DPB in BDOS
D48E 2AC6DE    LD      HL,($DEC6) ; disk size (nr blocks -1)
D491 7C        LD      A,H
D492 21DDDE    LD      HL,$DEDD	; (DEDD)=FF (for 8"SD) or 00 (for large cap. disk)
D495 36FF      LD      (HL),$FF
D497 B7        OR      A
D498 CA9DD4    JP      Z,$D49D
D49B 3600      LD      (HL),$00
D49D 3EFF      LD      A,$FF
D49F B7        OR      A
D4A0 C9        RET

D4A1 CD18DF    CALL    $DF18
D4A4 AF        XOR     A
D4A5 2AB5DE    LD      HL,($DEB5)
D4A8 77        LD      (HL),A
D4A9 23        INC     HL
D4AA 77        LD      (HL),A
D4AB 2AB7DE    LD      HL,($DEB7)
D4AE 77        LD      (HL),A
D4AF 23        INC     HL
D4B0 77        LD      (HL),A
D4B1 C9        RET

D4B2 CD27DF    CALL    $DF27
D4B5 C3BBD4    JP      $D4BB
D4B8 CD2ADF    CALL    $DF2A
D4BB B7        OR      A
D4BC C8        RET     Z

D4BD 2109D1    LD      HL,$D109
D4C0 C34AD4    JP      $D44A
D4C3 2AEADE    LD      HL,($DEEA)
D4C6 0E02      LD      C,$02
D4C8 CDEAD5    CALL    $D5EA
D4CB 22E5DE    LD      ($DEE5),HL
D4CE 22ECDE    LD      ($DEEC),HL
D4D1 21E5DE    LD      HL,$DEE5
D4D4 4E        LD      C,(HL)
D4D5 23        INC     HL
D4D6 46        LD      B,(HL)
D4D7 2AB7DE    LD      HL,($DEB7)
D4DA 5E        LD      E,(HL)
D4DB 23        INC     HL
D4DC 56        LD      D,(HL)
D4DD 2AB5DE    LD      HL,($DEB5)
D4E0 7E        LD      A,(HL)
D4E1 23        INC     HL
D4E2 66        LD      H,(HL)
D4E3 6F        LD      L,A
D4E4 79        LD      A,C
D4E5 93        SUB     E
D4E6 78        LD      A,B
D4E7 9A        SBC     A,D
D4E8 D2FAD4    JP      NC,$D4FA
D4EB E5        PUSH    HL
D4EC 2AC1DE    LD      HL,($DEC1)
D4EF 7B        LD      A,E
D4F0 95        SUB     L
D4F1 5F        LD      E,A
D4F2 7A        LD      A,D
D4F3 9C        SBC     A,H
D4F4 57        LD      D,A
D4F5 E1        POP     HL
D4F6 2B        DEC     HL
D4F7 C3E4D4    JP      $D4E4
D4FA E5        PUSH    HL
D4FB 2AC1DE    LD      HL,($DEC1)
D4FE 19        ADD     HL,DE
D4FF DA0FD5    JP      C,$D50F
D502 79        LD      A,C
D503 95        SUB     L
D504 78        LD      A,B
D505 9C        SBC     A,H
D506 DA0FD5    JP      C,$D50F
D509 EB        EX      DE,HL
D50A E1        POP     HL
D50B 23        INC     HL
D50C C3FAD4    JP      $D4FA
D50F E1        POP     HL
D510 C5        PUSH    BC
D511 D5        PUSH    DE
D512 E5        PUSH    HL
D513 EB        EX      DE,HL
D514 2ACEDE    LD      HL,($DECE)
D517 19        ADD     HL,DE
D518 44        LD      B,H
D519 4D        LD      C,L
D51A CD1EDF    CALL    $DF1E
D51D D1        POP     DE
D51E 2AB5DE    LD      HL,($DEB5)
D521 73        LD      (HL),E
D522 23        INC     HL
D523 72        LD      (HL),D
D524 D1        POP     DE
D525 2AB7DE    LD      HL,($DEB7)
D528 73        LD      (HL),E
D529 23        INC     HL
D52A 72        LD      (HL),D
D52B C1        POP     BC
D52C 79        LD      A,C
D52D 93        SUB     E
D52E 4F        LD      C,A
D52F 78        LD      A,B
D530 9A        SBC     A,D
D531 47        LD      B,A
D532 2AD0DE    LD      HL,($DED0)
D535 EB        EX      DE,HL
D536 CD30DF    CALL    $DF30
D539 4D        LD      C,L
D53A 44        LD      B,H
D53B C321DF    JP      $DF21
D53E 21C3DE    LD      HL,$DEC3
D541 4E        LD      C,(HL)
D542 3AE3DE    LD      A,($DEE3)
D545 B7        OR      A
D546 1F        RRA
D547 0D        DEC     C
D548 C245D5    JP      NZ,$D545
D54B 47        LD      B,A
D54C 3E08      LD      A,$08
D54E 96        SUB     (HL)
D54F 4F        LD      C,A
D550 3AE2DE    LD      A,($DEE2)
D553 0D        DEC     C
D554 CA5CD5    JP      Z,$D55C
D557 B7        OR      A
D558 17        RLA
D559 C353D5    JP      $D553
D55C 80        ADD     A,B
D55D C9        RET

D55E 2A43D4    LD      HL,($D443)
D561 111000    LD      DE,$0010
D564 19        ADD     HL,DE
D565 09        ADD     HL,BC
D566 3ADDDE    LD      A,($DEDD)
D569 B7        OR      A
D56A CA71D5    JP      Z,$D571
D56D 6E        LD      L,(HL)
D56E 2600      LD      H,$00
D570 C9        RET

D571 09        ADD     HL,BC
D572 5E        LD      E,(HL)
D573 23        INC     HL
D574 56        LD      D,(HL)
D575 EB        EX      DE,HL
D576 C9        RET

D577 CD3ED5    CALL    $D53E
D57A 4F        LD      C,A
D57B 0600      LD      B,$00
D57D CD5ED5    CALL    $D55E
D580 22E5DE    LD      ($DEE5),HL
D583 C9        RET

D584 2AE5DE    LD      HL,($DEE5)
D587 7D        LD      A,L
D588 B4        OR      H
D589 C9        RET

D58A 3AC3DE    LD      A,($DEC3)
D58D 2AE5DE    LD      HL,($DEE5)
D590 29        ADD     HL,HL
D591 3D        DEC     A
D592 C290D5    JP      NZ,$D590
D595 22E7DE    LD      ($DEE7),HL
D598 3AC4DE    LD      A,($DEC4)
D59B 4F        LD      C,A
D59C 3AE3DE    LD      A,($DEE3)
D59F A1        AND     C
D5A0 B5        OR      L
D5A1 6F        LD      L,A
D5A2 22E5DE    LD      ($DEE5),HL
D5A5 C9        RET

D5A6 2A43D4    LD      HL,($D443)
D5A9 110C00    LD      DE,$000C
D5AC 19        ADD     HL,DE
D5AD C9        RET

D5AE 2A43D4    LD      HL,($D443)
D5B1 110F00    LD      DE,$000F
D5B4 19        ADD     HL,DE
D5B5 EB        EX      DE,HL
D5B6 211100    LD      HL,$0011
D5B9 19        ADD     HL,DE
D5BA C9        RET

D5BB CDAED5    CALL    $D5AE
D5BE 7E        LD      A,(HL)
D5BF 32E3DE    LD      ($DEE3),A
D5C2 EB        EX      DE,HL
D5C3 7E        LD      A,(HL)
D5C4 32E1DE    LD      ($DEE1),A
D5C7 CDA6D5    CALL    $D5A6
D5CA 3AC5DE    LD      A,($DEC5)
D5CD A6        AND     (HL)
D5CE 32E2DE    LD      ($DEE2),A
D5D1 C9        RET

D5D2 CDAED5    CALL    $D5AE
D5D5 3AD5DE    LD      A,($DED5)
D5D8 FE02      CP      $02
D5DA C2DED5    JP      NZ,$D5DE
D5DD AF        XOR     A
D5DE 4F        LD      C,A
D5DF 3AE3DE    LD      A,($DEE3)
D5E2 81        ADD     A,C
D5E3 77        LD      (HL),A
D5E4 EB        EX      DE,HL
D5E5 3AE1DE    LD      A,($DEE1)
D5E8 77        LD      (HL),A
D5E9 C9        RET

D5EA 0C        INC     C	; ######## perform HL=HL/(2*C)
D5EB 0D        DEC     C	; <--- <--- <--- <---|
D5EC C8        RET     Z	; return if C is 00  |
D5ED 7C        LD      A,H	; \		     |
D5EE B7        OR      A	; | reset CY	     |
D5EF 1F        RRA		; |		     |
D5F0 67        LD      H,A	; | divide HL by 2   |
D5F1 7D        LD      A,L	; |		     |
D5F2 1F        RRA		; |		     |
D5F3 6F        LD      L,A	; /		     |
D5F4 C3EBD5    JP      $D5EB	; ---> ---> ---> --->|

D5F7 0E80      LD      C,$80
D5F9 2AB9DE    LD      HL,($DEB9)
D5FC AF        XOR     A
D5FD 86        ADD     A,(HL)
D5FE 23        INC     HL
D5FF 0D        DEC     C
D600 C2FDD5    JP      NZ,$D5FD
D603 C9        RET

D604 0C        INC     C
D605 0D        DEC     C
D606 C8        RET     Z

D607 29        ADD     HL,HL
D608 C305D6    JP      $D605
				; ######### SETVEC - set log in vector ##########
D60B C5        PUSH    BC	; save log in vector
D60C 3A42D4    LD      A,($D442) ; current disk
D60F 4F        LD      C,A	; stored in C
D610 210100    LD      HL,$0001	; log in bit as bit 1 of HL
D613 CD04D6    CALL    $D604	; shift HL left as per count in C
D616 C1        POP     BC
D617 79        LD      A,C
D618 B5        OR      L
D619 6F        LD      L,A
D61A 78        LD      A,B
D61B B4        OR      H
D61C 67        LD      H,A
D61D C9        RET

D61E 2AADDE    LD      HL,($DEAD)
D621 3A42D4    LD      A,($D442)
D624 4F        LD      C,A
D625 CDEAD5    CALL    $D5EA
D628 7D        LD      A,L
D629 E601      AND     $01
D62B C9        RET

D62C 21ADDE    LD      HL,$DEAD
D62F 4E        LD      C,(HL)
D630 23        INC     HL
D631 46        LD      B,(HL)
D632 CD0BD6    CALL    $D60B
D635 22ADDE    LD      ($DEAD),HL
D638 2AC8DE    LD      HL,($DEC8)
D63B 23        INC     HL
D63C EB        EX      DE,HL
D63D 2AB3DE    LD      HL,($DEB3)
D640 73        LD      (HL),E
D641 23        INC     HL
D642 72        LD      (HL),D
D643 C9        RET

D644 CD5ED6    CALL    $D65E
D647 110900    LD      DE,$0009
D64A 19        ADD     HL,DE
D64B 7E        LD      A,(HL)
D64C 17        RLA
D64D D0        RET     NC

D64E 210FD1    LD      HL,$D10F
D651 C34AD4    JP      $D44A
D654 CD1ED6    CALL    $D61E
D657 C8        RET     Z

D658 210DD1    LD      HL,$D10D
D65B C34AD4    JP      $D44A
D65E 2AB9DE    LD      HL,($DEB9)
D661 3AE9DE    LD      A,($DEE9)
D664 85        ADD     A,L
D665 6F        LD      L,A
D666 D0        RET     NC

D667 24        INC     H
D668 C9        RET

D669 2A43D4    LD      HL,($D443)
D66C 110E00    LD      DE,$000E
D66F 19        ADD     HL,DE
D670 7E        LD      A,(HL)
D671 C9        RET

D672 CD69D6    CALL    $D669
D675 3600      LD      (HL),$00
D677 C9        RET

D678 CD69D6    CALL    $D669
D67B F680      OR      $80
D67D 77        LD      (HL),A
D67E C9        RET

D67F 2AEADE    LD      HL,($DEEA)
D682 EB        EX      DE,HL
D683 2AB3DE    LD      HL,($DEB3)
D686 7B        LD      A,E
D687 96        SUB     (HL)
D688 23        INC     HL
D689 7A        LD      A,D
D68A 9E        SBC     A,(HL)
D68B C9        RET

D68C CD7FD6    CALL    $D67F
D68F D8        RET     C

D690 13        INC     DE
D691 72        LD      (HL),D
D692 2B        DEC     HL
D693 73        LD      (HL),E
D694 C9        RET

D695 7B        LD      A,E
D696 95        SUB     L
D697 6F        LD      L,A
D698 7A        LD      A,D
D699 9C        SBC     A,H
D69A 67        LD      H,A
D69B C9        RET

D69C 0EFF      LD      C,$FF
D69E 2AECDE    LD      HL,($DEEC)
D6A1 EB        EX      DE,HL
D6A2 2ACCDE    LD      HL,($DECC)
D6A5 CD95D6    CALL    $D695
D6A8 D0        RET     NC

D6A9 C5        PUSH    BC
D6AA CDF7D5    CALL    $D5F7
D6AD 2ABDDE    LD      HL,($DEBD)
D6B0 EB        EX      DE,HL
D6B1 2AECDE    LD      HL,($DEEC)
D6B4 19        ADD     HL,DE
D6B5 C1        POP     BC
D6B6 0C        INC     C
D6B7 CAC4D6    JP      Z,$D6C4
D6BA BE        CP      (HL)
D6BB C8        RET     Z

D6BC CD7FD6    CALL    $D67F
D6BF D0        RET     NC

D6C0 CD2CD6    CALL    $D62C
D6C3 C9        RET

D6C4 77        LD      (HL),A
D6C5 C9        RET

D6C6 CD9CD6    CALL    $D69C
D6C9 CDE0D6    CALL    $D6E0
D6CC 0E01      LD      C,$01
D6CE CDB8D4    CALL    $D4B8
D6D1 C3DAD6    JP      $D6DA
D6D4 CDE0D6    CALL    $D6E0
D6D7 CDB2D4    CALL    $D4B2
D6DA 21B1DE    LD      HL,$DEB1	; DMA address
D6DD C3E3D6    JP      $D6E3	; --->|
D6E0 21B9DE    LD      HL,$DEB9	;     |
D6E3 4E        LD      C,(HL)	; <---|
D6E4 23        INC     HL
D6E5 46        LD      B,(HL)	; BC = DMA Address
D6E6 C324DF    JP      $DF24	; jump to BIOS SETDMA function

D6E9 2AB9DE    LD      HL,($DEB9)
D6EC EB        EX      DE,HL
D6ED 2AB1DE    LD      HL,($DEB1)
D6F0 0E80      LD      C,$80
D6F2 C34FD4    JP      $D44F
D6F5 21EADE    LD      HL,$DEEA
D6F8 7E        LD      A,(HL)
D6F9 23        INC     HL
D6FA BE        CP      (HL)
D6FB C0        RET     NZ

D6FC 3C        INC     A
D6FD C9        RET

D6FE 21FFFF    LD      HL,$FFFF
D701 22EADE    LD      ($DEEA),HL
D704 C9        RET

D705 2AC8DE    LD      HL,($DEC8)
D708 EB        EX      DE,HL
D709 2AEADE    LD      HL,($DEEA)
D70C 23        INC     HL
D70D 22EADE    LD      ($DEEA),HL
D710 CD95D6    CALL    $D695
D713 D219D7    JP      NC,$D719
D716 C3FED6    JP      $D6FE
D719 3AEADE    LD      A,($DEEA)
D71C E603      AND     $03
D71E 0605      LD      B,$05
D720 87        ADD     A,A
D721 05        DEC     B
D722 C220D7    JP      NZ,$D720
D725 32E9DE    LD      ($DEE9),A
D728 B7        OR      A
D729 C0        RET     NZ

D72A C5        PUSH    BC
D72B CDC3D4    CALL    $D4C3
D72E CDD4D6    CALL    $D6D4
D731 C1        POP     BC
D732 C39ED6    JP      $D69E
D735 79        LD      A,C
D736 E607      AND     $07
D738 3C        INC     A
D739 5F        LD      E,A
D73A 57        LD      D,A
D73B 79        LD      A,C
D73C 0F        RRCA
D73D 0F        RRCA
D73E 0F        RRCA
D73F E61F      AND     $1F
D741 4F        LD      C,A
D742 78        LD      A,B
D743 87        ADD     A,A
D744 87        ADD     A,A
D745 87        ADD     A,A
D746 87        ADD     A,A
D747 87        ADD     A,A
D748 B1        OR      C
D749 4F        LD      C,A
D74A 78        LD      A,B
D74B 0F        RRCA
D74C 0F        RRCA
D74D 0F        RRCA
D74E E61F      AND     $1F
D750 47        LD      B,A
D751 2ABFDE    LD      HL,($DEBF)
D754 09        ADD     HL,BC
D755 7E        LD      A,(HL)
D756 07        RLCA
D757 1D        DEC     E
D758 C256D7    JP      NZ,$D756
D75B C9        RET

D75C D5        PUSH    DE
D75D CD35D7    CALL    $D735
D760 E6FE      AND     $FE
D762 C1        POP     BC
D763 B1        OR      C
D764 0F        RRCA
D765 15        DEC     D
D766 C264D7    JP      NZ,$D764
D769 77        LD      (HL),A
D76A C9        RET

D76B CD5ED6    CALL    $D65E
D76E 111000    LD      DE,$0010
D771 19        ADD     HL,DE
D772 C5        PUSH    BC
D773 0E11      LD      C,$11
D775 D1        POP     DE
D776 0D        DEC     C
D777 C8        RET     Z

D778 D5        PUSH    DE
D779 3ADDDE    LD      A,($DEDD)
D77C B7        OR      A
D77D CA88D7    JP      Z,$D788
D780 C5        PUSH    BC
D781 E5        PUSH    HL
D782 4E        LD      C,(HL)
D783 0600      LD      B,$00
D785 C38ED7    JP      $D78E
D788 0D        DEC     C
D789 C5        PUSH    BC
D78A 4E        LD      C,(HL)
D78B 23        INC     HL
D78C 46        LD      B,(HL)
D78D E5        PUSH    HL
D78E 79        LD      A,C
D78F B0        OR      B
D790 CA9DD7    JP      Z,$D79D
D793 2AC6DE    LD      HL,($DEC6)
D796 7D        LD      A,L
D797 91        SUB     C
D798 7C        LD      A,H
D799 98        SBC     A,B
D79A D45CD7    CALL    NC,$D75C
D79D E1        POP     HL
D79E 23        INC     HL
D79F C1        POP     BC
D7A0 C375D7    JP      $D775
D7A3 2AC6DE    LD      HL,($DEC6)
D7A6 0E03      LD      C,$03
D7A8 CDEAD5    CALL    $D5EA
D7AB 23        INC     HL
D7AC 44        LD      B,H
D7AD 4D        LD      C,L
D7AE 2ABFDE    LD      HL,($DEBF)
D7B1 3600      LD      (HL),$00
D7B3 23        INC     HL
D7B4 0B        DEC     BC
D7B5 78        LD      A,B
D7B6 B1        OR      C
D7B7 C2B1D7    JP      NZ,$D7B1
D7BA 2ACADE    LD      HL,($DECA)
D7BD EB        EX      DE,HL
D7BE 2ABFDE    LD      HL,($DEBF)
D7C1 73        LD      (HL),E
D7C2 23        INC     HL
D7C3 72        LD      (HL),D
D7C4 CDA1D4    CALL    $D4A1
D7C7 2AB3DE    LD      HL,($DEB3)
D7CA 3603      LD      (HL),$03
D7CC 23        INC     HL
D7CD 3600      LD      (HL),$00
D7CF CDFED6    CALL    $D6FE
D7D2 0EFF      LD      C,$FF
D7D4 CD05D7    CALL    $D705
D7D7 CDF5D6    CALL    $D6F5
D7DA C8        RET     Z

D7DB CD5ED6    CALL    $D65E
D7DE 3EE5      LD      A,$E5
D7E0 BE        CP      (HL)
D7E1 CAD2D7    JP      Z,$D7D2
D7E4 3A41D4    LD      A,($D441)
D7E7 BE        CP      (HL)
D7E8 C2F6D7    JP      NZ,$D7F6
D7EB 23        INC     HL
D7EC 7E        LD      A,(HL)
D7ED D624      SUB     $24
D7EF C2F6D7    JP      NZ,$D7F6
D7F2 3D        DEC     A
D7F3 3245D4    LD      ($D445),A
D7F6 0E01      LD      C,$01
D7F8 CD6BD7    CALL    $D76B
D7FB CD8CD6    CALL    $D68C
D7FE C3D2D7    JP      $D7D2
D801 3AD4DE    LD      A,($DED4)
D804 C301D4    JP      $D401
D807 C5        PUSH    BC
D808 F5        PUSH    AF
D809 3AC5DE    LD      A,($DEC5)
D80C 2F        CPL
D80D 47        LD      B,A
D80E 79        LD      A,C
D80F A0        AND     B
D810 4F        LD      C,A
D811 F1        POP     AF
D812 A0        AND     B
D813 91        SUB     C
D814 E61F      AND     $1F
D816 C1        POP     BC
D817 C9        RET

D818 3EFF      LD      A,$FF
D81A 32D4DE    LD      ($DED4),A
D81D 21D8DE    LD      HL,$DED8
D820 71        LD      (HL),C
D821 2A43D4    LD      HL,($D443)
D824 22D9DE    LD      ($DED9),HL
D827 CDFED6    CALL    $D6FE
D82A CDA1D4    CALL    $D4A1
D82D 0E00      LD      C,$00
D82F CD05D7    CALL    $D705
D832 CDF5D6    CALL    $D6F5
D835 CA94D8    JP      Z,$D894
D838 2AD9DE    LD      HL,($DED9)
D83B EB        EX      DE,HL
D83C 1A        LD      A,(DE)
D83D FEE5      CP      $E5
D83F CA4AD8    JP      Z,$D84A
D842 D5        PUSH    DE
D843 CD7FD6    CALL    $D67F
D846 D1        POP     DE
D847 D294D8    JP      NC,$D894
D84A CD5ED6    CALL    $D65E
D84D 3AD8DE    LD      A,($DED8)
D850 4F        LD      C,A
D851 0600      LD      B,$00
D853 79        LD      A,C
D854 B7        OR      A
D855 CA83D8    JP      Z,$D883
D858 1A        LD      A,(DE)
D859 FE3F      CP      $3F
D85B CA7CD8    JP      Z,$D87C
D85E 78        LD      A,B
D85F FE0D      CP      $0D
D861 CA7CD8    JP      Z,$D87C
D864 FE0C      CP      $0C
D866 1A        LD      A,(DE)
D867 CA73D8    JP      Z,$D873
D86A 96        SUB     (HL)
D86B E67F      AND     $7F
D86D C22DD8    JP      NZ,$D82D
D870 C37CD8    JP      $D87C
D873 C5        PUSH    BC
D874 4E        LD      C,(HL)
D875 CD07D8    CALL    $D807
D878 C1        POP     BC
D879 C22DD8    JP      NZ,$D82D
D87C 13        INC     DE
D87D 23        INC     HL
D87E 04        INC     B
D87F 0D        DEC     C
D880 C353D8    JP      $D853
D883 3AEADE    LD      A,($DEEA)
D886 E603      AND     $03
D888 3245D4    LD      ($D445),A
D88B 21D4DE    LD      HL,$DED4
D88E 7E        LD      A,(HL)
D88F 17        RLA
D890 D0        RET     NC

D891 AF        XOR     A
D892 77        LD      (HL),A
D893 C9        RET

D894 CDFED6    CALL    $D6FE
D897 3EFF      LD      A,$FF
D899 C301D4    JP      $D401
D89C CD54D6    CALL    $D654
D89F 0E0C      LD      C,$0C
D8A1 CD18D8    CALL    $D818
D8A4 CDF5D6    CALL    $D6F5
D8A7 C8        RET     Z

D8A8 CD44D6    CALL    $D644
D8AB CD5ED6    CALL    $D65E
D8AE 36E5      LD      (HL),$E5
D8B0 0E00      LD      C,$00
D8B2 CD6BD7    CALL    $D76B
D8B5 CDC6D6    CALL    $D6C6
D8B8 CD2DD8    CALL    $D82D
D8BB C3A4D8    JP      $D8A4
D8BE 50        LD      D,B
D8BF 59        LD      E,C
D8C0 79        LD      A,C
D8C1 B0        OR      B
D8C2 CAD1D8    JP      Z,$D8D1
D8C5 0B        DEC     BC
D8C6 D5        PUSH    DE
D8C7 C5        PUSH    BC
D8C8 CD35D7    CALL    $D735
D8CB 1F        RRA
D8CC D2ECD8    JP      NC,$D8EC
D8CF C1        POP     BC
D8D0 D1        POP     DE
D8D1 2AC6DE    LD      HL,($DEC6)
D8D4 7B        LD      A,E
D8D5 95        SUB     L
D8D6 7A        LD      A,D
D8D7 9C        SBC     A,H
D8D8 D2F4D8    JP      NC,$D8F4
D8DB 13        INC     DE
D8DC C5        PUSH    BC
D8DD D5        PUSH    DE
D8DE 42        LD      B,D
D8DF 4B        LD      C,E
D8E0 CD35D7    CALL    $D735
D8E3 1F        RRA
D8E4 D2ECD8    JP      NC,$D8EC
D8E7 D1        POP     DE
D8E8 C1        POP     BC
D8E9 C3C0D8    JP      $D8C0
D8EC 17        RLA
D8ED 3C        INC     A
D8EE CD64D7    CALL    $D764
D8F1 E1        POP     HL
D8F2 D1        POP     DE
D8F3 C9        RET

D8F4 79        LD      A,C
D8F5 B0        OR      B
D8F6 C2C0D8    JP      NZ,$D8C0
D8F9 210000    LD      HL,$0000
D8FC C9        RET

D8FD 0E00      LD      C,$00
D8FF 1E20      LD      E,$20
D901 D5        PUSH    DE
D902 0600      LD      B,$00
D904 2A43D4    LD      HL,($D443)
D907 09        ADD     HL,BC
D908 EB        EX      DE,HL
D909 CD5ED6    CALL    $D65E
D90C C1        POP     BC
D90D CD4FD4    CALL    $D44F
D910 CDC3D4    CALL    $D4C3
D913 C3C6D6    JP      $D6C6
D916 CD54D6    CALL    $D654
D919 0E0C      LD      C,$0C
D91B CD18D8    CALL    $D818
D91E 2A43D4    LD      HL,($D443)
D921 7E        LD      A,(HL)
D922 111000    LD      DE,$0010
D925 19        ADD     HL,DE
D926 77        LD      (HL),A
D927 CDF5D6    CALL    $D6F5
D92A C8        RET     Z

D92B CD44D6    CALL    $D644
D92E 0E10      LD      C,$10
D930 1E0C      LD      E,$0C
D932 CD01D9    CALL    $D901
D935 CD2DD8    CALL    $D82D
D938 C327D9    JP      $D927
D93B 0E0C      LD      C,$0C
D93D CD18D8    CALL    $D818
D940 CDF5D6    CALL    $D6F5
D943 C8        RET     Z

D944 0E00      LD      C,$00
D946 1E0C      LD      E,$0C
D948 CD01D9    CALL    $D901
D94B CD2DD8    CALL    $D82D
D94E C340D9    JP      $D940
D951 0E0F      LD      C,$0F
D953 CD18D8    CALL    $D818
D956 CDF5D6    CALL    $D6F5
D959 C8        RET     Z

D95A CDA6D5    CALL    $D5A6
D95D 7E        LD      A,(HL)
D95E F5        PUSH    AF
D95F E5        PUSH    HL
D960 CD5ED6    CALL    $D65E
D963 EB        EX      DE,HL
D964 2A43D4    LD      HL,($D443)
D967 0E20      LD      C,$20
D969 D5        PUSH    DE
D96A CD4FD4    CALL    $D44F
D96D CD78D6    CALL    $D678
D970 D1        POP     DE
D971 210C00    LD      HL,$000C
D974 19        ADD     HL,DE
D975 4E        LD      C,(HL)
D976 210F00    LD      HL,$000F
D979 19        ADD     HL,DE
D97A 46        LD      B,(HL)
D97B E1        POP     HL
D97C F1        POP     AF
D97D 77        LD      (HL),A
D97E 79        LD      A,C
D97F BE        CP      (HL)
D980 78        LD      A,B
D981 CA8BD9    JP      Z,$D98B
D984 3E00      LD      A,$00
D986 DA8BD9    JP      C,$D98B
D989 3E80      LD      A,$80
D98B 2A43D4    LD      HL,($D443)
D98E 110F00    LD      DE,$000F
D991 19        ADD     HL,DE
D992 77        LD      (HL),A
D993 C9        RET

D994 7E        LD      A,(HL)
D995 23        INC     HL
D996 B6        OR      (HL)
D997 2B        DEC     HL
D998 C0        RET     NZ

D999 1A        LD      A,(DE)
D99A 77        LD      (HL),A
D99B 13        INC     DE
D99C 23        INC     HL
D99D 1A        LD      A,(DE)
D99E 77        LD      (HL),A
D99F 1B        DEC     DE
D9A0 2B        DEC     HL
D9A1 C9        RET

D9A2 AF        XOR     A
D9A3 3245D4    LD      ($D445),A
D9A6 32EADE    LD      ($DEEA),A
D9A9 32EBDE    LD      ($DEEB),A
D9AC CD1ED6    CALL    $D61E
D9AF C0        RET     NZ

D9B0 CD69D6    CALL    $D669
D9B3 E680      AND     $80
D9B5 C0        RET     NZ

D9B6 0E0F      LD      C,$0F
D9B8 CD18D8    CALL    $D818
D9BB CDF5D6    CALL    $D6F5
D9BE C8        RET     Z

D9BF 011000    LD      BC,$0010
D9C2 CD5ED6    CALL    $D65E
D9C5 09        ADD     HL,BC
D9C6 EB        EX      DE,HL
D9C7 2A43D4    LD      HL,($D443)
D9CA 09        ADD     HL,BC
D9CB 0E10      LD      C,$10
D9CD 3ADDDE    LD      A,($DEDD)
D9D0 B7        OR      A
D9D1 CAE8D9    JP      Z,$D9E8
D9D4 7E        LD      A,(HL)
D9D5 B7        OR      A
D9D6 1A        LD      A,(DE)
D9D7 C2DBD9    JP      NZ,$D9DB
D9DA 77        LD      (HL),A
D9DB B7        OR      A
D9DC C2E1D9    JP      NZ,$D9E1
D9DF 7E        LD      A,(HL)
D9E0 12        LD      (DE),A
D9E1 BE        CP      (HL)
D9E2 C21FDA    JP      NZ,$DA1F
D9E5 C3FDD9    JP      $D9FD
D9E8 CD94D9    CALL    $D994
D9EB EB        EX      DE,HL
D9EC CD94D9    CALL    $D994
D9EF EB        EX      DE,HL
D9F0 1A        LD      A,(DE)
D9F1 BE        CP      (HL)
D9F2 C21FDA    JP      NZ,$DA1F
D9F5 13        INC     DE
D9F6 23        INC     HL
D9F7 1A        LD      A,(DE)
D9F8 BE        CP      (HL)
D9F9 C21FDA    JP      NZ,$DA1F
D9FC 0D        DEC     C
D9FD 13        INC     DE
D9FE 23        INC     HL
D9FF 0D        DEC     C
DA00 C2CDD9    JP      NZ,$D9CD
DA03 01ECFF    LD      BC,$FFEC
DA06 09        ADD     HL,BC
DA07 EB        EX      DE,HL
DA08 09        ADD     HL,BC
DA09 1A        LD      A,(DE)
DA0A BE        CP      (HL)
DA0B DA17DA    JP      C,$DA17
DA0E 77        LD      (HL),A
DA0F 010300    LD      BC,$0003
DA12 09        ADD     HL,BC
DA13 EB        EX      DE,HL
DA14 09        ADD     HL,BC
DA15 7E        LD      A,(HL)
DA16 12        LD      (DE),A
DA17 3EFF      LD      A,$FF
DA19 32D2DE    LD      ($DED2),A
DA1C C310D9    JP      $D910
DA1F 2145D4    LD      HL,$D445
DA22 35        DEC     (HL)
DA23 C9        RET

DA24 CD54D6    CALL    $D654
DA27 2A43D4    LD      HL,($D443)
DA2A E5        PUSH    HL
DA2B 21ACDE    LD      HL,$DEAC
DA2E 2243D4    LD      ($D443),HL
DA31 0E01      LD      C,$01
DA33 CD18D8    CALL    $D818
DA36 CDF5D6    CALL    $D6F5
DA39 E1        POP     HL
DA3A 2243D4    LD      ($D443),HL
DA3D C8        RET     Z

DA3E EB        EX      DE,HL
DA3F 210F00    LD      HL,$000F
DA42 19        ADD     HL,DE
DA43 0E11      LD      C,$11
DA45 AF        XOR     A
DA46 77        LD      (HL),A
DA47 23        INC     HL
DA48 0D        DEC     C
DA49 C246DA    JP      NZ,$DA46
DA4C 210D00    LD      HL,$000D
DA4F 19        ADD     HL,DE
DA50 77        LD      (HL),A
DA51 CD8CD6    CALL    $D68C
DA54 CDFDD8    CALL    $D8FD
DA57 C378D6    JP      $D678
DA5A AF        XOR     A
DA5B 32D2DE    LD      ($DED2),A
DA5E CDA2D9    CALL    $D9A2
DA61 CDF5D6    CALL    $D6F5
DA64 C8        RET     Z

DA65 2A43D4    LD      HL,($D443)
DA68 010C00    LD      BC,$000C
DA6B 09        ADD     HL,BC
DA6C 7E        LD      A,(HL)
DA6D 3C        INC     A
DA6E E61F      AND     $1F
DA70 77        LD      (HL),A
DA71 CA83DA    JP      Z,$DA83
DA74 47        LD      B,A
DA75 3AC5DE    LD      A,($DEC5)
DA78 A0        AND     B
DA79 21D2DE    LD      HL,$DED2
DA7C A6        AND     (HL)
DA7D CA8EDA    JP      Z,$DA8E
DA80 C3ACDA    JP      $DAAC
DA83 010200    LD      BC,$0002
DA86 09        ADD     HL,BC
DA87 34        INC     (HL)
DA88 7E        LD      A,(HL)
DA89 E60F      AND     $0F
DA8B CAB6DA    JP      Z,$DAB6
DA8E 0E0F      LD      C,$0F
DA90 CD18D8    CALL    $D818
DA93 CDF5D6    CALL    $D6F5
DA96 C2ACDA    JP      NZ,$DAAC
DA99 3AD3DE    LD      A,($DED3)
DA9C 3C        INC     A
DA9D CAB6DA    JP      Z,$DAB6
DAA0 CD24DA    CALL    $DA24
DAA3 CDF5D6    CALL    $D6F5
DAA6 CAB6DA    JP      Z,$DAB6
DAA9 C3AFDA    JP      $DAAF
DAAC CD5AD9    CALL    $D95A
DAAF CDBBD5    CALL    $D5BB
DAB2 AF        XOR     A
DAB3 C301D4    JP      $D401
DAB6 CD05D4    CALL    $D405
DAB9 C378D6    JP      $D678
					; ######### RDSEQ (READ SEQUENTIAL) #########
DABC 3E01      LD      A,$01
DABE 32D5DE    LD      ($DED5),A
DAC1 3EFF      LD      A,$FF
DAC3 32D3DE    LD      ($DED3),A
DAC6 CDBBD5    CALL    $D5BB
DAC9 3AE3DE    LD      A,($DEE3)
DACC 21E1DE    LD      HL,$DEE1
DACF BE        CP      (HL)
DAD0 DAE6DA    JP      C,$DAE6
DAD3 FE80      CP      $80
DAD5 C2FBDA    JP      NZ,$DAFB
DAD8 CD5ADA    CALL    $DA5A
DADB AF        XOR     A
DADC 32E3DE    LD      ($DEE3),A
DADF 3A45D4    LD      A,($D445)
DAE2 B7        OR      A
DAE3 C2FBDA    JP      NZ,$DAFB
DAE6 CD77D5    CALL    $D577
DAE9 CD84D5    CALL    $D584
DAEC CAFBDA    JP      Z,$DAFB
DAEF CD8AD5    CALL    $D58A
DAF2 CDD1D4    CALL    $D4D1
DAF5 CDB2D4    CALL    $D4B2
DAF8 C3D2D5    JP      $D5D2
DAFB C305D4    JP      $D405
DAFE 3E01      LD      A,$01
DB00 32D5DE    LD      ($DED5),A
DB03 3E00      LD      A,$00
DB05 32D3DE    LD      ($DED3),A
DB08 CD54D6    CALL    $D654
DB0B 2A43D4    LD      HL,($D443)
DB0E CD47D6    CALL    $D647
DB11 CDBBD5    CALL    $D5BB
DB14 3AE3DE    LD      A,($DEE3)
DB17 FE80      CP      $80
DB19 D205D4    JP      NC,$D405
DB1C CD77D5    CALL    $D577
DB1F CD84D5    CALL    $D584
DB22 0E00      LD      C,$00
DB24 C26EDB    JP      NZ,$DB6E
DB27 CD3ED5    CALL    $D53E
DB2A 32D7DE    LD      ($DED7),A
DB2D 010000    LD      BC,$0000
DB30 B7        OR      A
DB31 CA3BDB    JP      Z,$DB3B
DB34 4F        LD      C,A
DB35 0B        DEC     BC
DB36 CD5ED5    CALL    $D55E
DB39 44        LD      B,H
DB3A 4D        LD      C,L
DB3B CDBED8    CALL    $D8BE
DB3E 7D        LD      A,L
DB3F B4        OR      H
DB40 C248DB    JP      NZ,$DB48
DB43 3E02      LD      A,$02
DB45 C301D4    JP      $D401
DB48 22E5DE    LD      ($DEE5),HL
DB4B EB        EX      DE,HL
DB4C 2A43D4    LD      HL,($D443)
DB4F 011000    LD      BC,$0010
DB52 09        ADD     HL,BC
DB53 3ADDDE    LD      A,($DEDD)
DB56 B7        OR      A
DB57 3AD7DE    LD      A,($DED7)
DB5A CA64DB    JP      Z,$DB64
DB5D CD64D6    CALL    $D664
DB60 73        LD      (HL),E
DB61 C36CDB    JP      $DB6C
DB64 4F        LD      C,A
DB65 0600      LD      B,$00
DB67 09        ADD     HL,BC
DB68 09        ADD     HL,BC
DB69 73        LD      (HL),E
DB6A 23        INC     HL
DB6B 72        LD      (HL),D
DB6C 0E02      LD      C,$02
DB6E 3A45D4    LD      A,($D445)
DB71 B7        OR      A
DB72 C0        RET     NZ

DB73 C5        PUSH    BC
DB74 CD8AD5    CALL    $D58A
DB77 3AD5DE    LD      A,($DED5)
DB7A 3D        DEC     A
DB7B 3D        DEC     A
DB7C C2BBDB    JP      NZ,$DBBB
DB7F C1        POP     BC
DB80 C5        PUSH    BC
DB81 79        LD      A,C
DB82 3D        DEC     A
DB83 3D        DEC     A
DB84 C2BBDB    JP      NZ,$DBBB
DB87 E5        PUSH    HL
DB88 2AB9DE    LD      HL,($DEB9)
DB8B 57        LD      D,A
DB8C 77        LD      (HL),A
DB8D 23        INC     HL
DB8E 14        INC     D
DB8F F28CDB    JP      P,$DB8C
DB92 CDE0D6    CALL    $D6E0
DB95 2AE7DE    LD      HL,($DEE7)
DB98 0E02      LD      C,$02
DB9A 22E5DE    LD      ($DEE5),HL
DB9D C5        PUSH    BC
DB9E CDD1D4    CALL    $D4D1
DBA1 C1        POP     BC
DBA2 CDB8D4    CALL    $D4B8
DBA5 2AE5DE    LD      HL,($DEE5)
DBA8 0E00      LD      C,$00
DBAA 3AC4DE    LD      A,($DEC4)
DBAD 47        LD      B,A
DBAE A5        AND     L
DBAF B8        CP      B
DBB0 23        INC     HL
DBB1 C29ADB    JP      NZ,$DB9A
DBB4 E1        POP     HL
DBB5 22E5DE    LD      ($DEE5),HL
DBB8 CDDAD6    CALL    $D6DA
DBBB CDD1D4    CALL    $D4D1
DBBE C1        POP     BC
DBBF C5        PUSH    BC
DBC0 CDB8D4    CALL    $D4B8
DBC3 C1        POP     BC
DBC4 3AE3DE    LD      A,($DEE3)
DBC7 21E1DE    LD      HL,$DEE1
DBCA BE        CP      (HL)
DBCB DAD2DB    JP      C,$DBD2
DBCE 77        LD      (HL),A
DBCF 34        INC     (HL)
DBD0 0E02      LD      C,$02
DBD2 00        NOP
DBD3 00        NOP
DBD4 2100C9    LD      HL,$C900
DBD7 F5        PUSH    AF
DBD8 CD69D6    CALL    $D669
DBDB E67F      AND     $7F
DBDD 77        LD      (HL),A
DBDE F1        POP     AF
DBDF FE7F      CP      $7F
DBE1 C200DC    JP      NZ,$DC00
DBE4 3AD5DE    LD      A,($DED5)
DBE7 FE01      CP      $01
DBE9 C200DC    JP      NZ,$DC00
DBEC CDD2D5    CALL    $D5D2
DBEF CD5ADA    CALL    $DA5A
DBF2 2145D4    LD      HL,$D445
DBF5 7E        LD      A,(HL)
DBF6 B7        OR      A
DBF7 C2FEDB    JP      NZ,$DBFE
DBFA 3D        DEC     A
DBFB 32E3DE    LD      ($DEE3),A
DBFE 3600      LD      (HL),$00
DC00 C3D2D5    JP      $D5D2
DC03 AF        XOR     A
DC04 32D5DE    LD      ($DED5),A
DC07 C5        PUSH    BC
DC08 2A43D4    LD      HL,($D443)
DC0B EB        EX      DE,HL
DC0C 212100    LD      HL,$0021
DC0F 19        ADD     HL,DE
DC10 7E        LD      A,(HL)
DC11 E67F      AND     $7F
DC13 F5        PUSH    AF
DC14 7E        LD      A,(HL)
DC15 17        RLA
DC16 23        INC     HL
DC17 7E        LD      A,(HL)
DC18 17        RLA
DC19 E61F      AND     $1F
DC1B 4F        LD      C,A
DC1C 7E        LD      A,(HL)
DC1D 1F        RRA
DC1E 1F        RRA
DC1F 1F        RRA
DC20 1F        RRA
DC21 E60F      AND     $0F
DC23 47        LD      B,A
DC24 F1        POP     AF
DC25 23        INC     HL
DC26 6E        LD      L,(HL)
DC27 2C        INC     L
DC28 2D        DEC     L
DC29 2E06      LD      L,$06
DC2B C28BDC    JP      NZ,$DC8B
DC2E 212000    LD      HL,$0020
DC31 19        ADD     HL,DE
DC32 77        LD      (HL),A
DC33 210C00    LD      HL,$000C
DC36 19        ADD     HL,DE
DC37 79        LD      A,C
DC38 96        SUB     (HL)
DC39 C247DC    JP      NZ,$DC47
DC3C 210E00    LD      HL,$000E
DC3F 19        ADD     HL,DE
DC40 78        LD      A,B
DC41 96        SUB     (HL)
DC42 E67F      AND     $7F
DC44 CA7FDC    JP      Z,$DC7F
DC47 C5        PUSH    BC
DC48 D5        PUSH    DE
DC49 CDA2D9    CALL    $D9A2
DC4C D1        POP     DE
DC4D C1        POP     BC
DC4E 2E03      LD      L,$03
DC50 3A45D4    LD      A,($D445)
DC53 3C        INC     A
DC54 CA84DC    JP      Z,$DC84
DC57 210C00    LD      HL,$000C
DC5A 19        ADD     HL,DE
DC5B 71        LD      (HL),C
DC5C 210E00    LD      HL,$000E
DC5F 19        ADD     HL,DE
DC60 70        LD      (HL),B
DC61 CD51D9    CALL    $D951
DC64 3A45D4    LD      A,($D445)
DC67 3C        INC     A
DC68 C27FDC    JP      NZ,$DC7F
DC6B C1        POP     BC
DC6C C5        PUSH    BC
DC6D 2E04      LD      L,$04
DC6F 0C        INC     C
DC70 CA84DC    JP      Z,$DC84
DC73 CD24DA    CALL    $DA24
DC76 2E05      LD      L,$05
DC78 3A45D4    LD      A,($D445)
DC7B 3C        INC     A
DC7C CA84DC    JP      Z,$DC84
DC7F C1        POP     BC
DC80 AF        XOR     A
DC81 C301D4    JP      $D401
DC84 E5        PUSH    HL
DC85 CD69D6    CALL    $D669
DC88 36C0      LD      (HL),$C0
DC8A E1        POP     HL
DC8B C1        POP     BC
DC8C 7D        LD      A,L
DC8D 3245D4    LD      ($D445),A
DC90 C378D6    JP      $D678
DC93 0EFF      LD      C,$FF
DC95 CD03DC    CALL    $DC03
DC98 CCC1DA    CALL    Z,$DAC1
DC9B C9        RET

DC9C 0E00      LD      C,$00
DC9E CD03DC    CALL    $DC03
DCA1 CC03DB    CALL    Z,$DB03
DCA4 C9        RET

DCA5 EB        EX      DE,HL
DCA6 19        ADD     HL,DE
DCA7 4E        LD      C,(HL)
DCA8 0600      LD      B,$00
DCAA 210C00    LD      HL,$000C
DCAD 19        ADD     HL,DE
DCAE 7E        LD      A,(HL)
DCAF 0F        RRCA
DCB0 E680      AND     $80
DCB2 81        ADD     A,C
DCB3 4F        LD      C,A
DCB4 3E00      LD      A,$00
DCB6 88        ADC     A,B
DCB7 47        LD      B,A
DCB8 7E        LD      A,(HL)
DCB9 0F        RRCA
DCBA E60F      AND     $0F
DCBC 80        ADD     A,B
DCBD 47        LD      B,A
DCBE 210E00    LD      HL,$000E
DCC1 19        ADD     HL,DE
DCC2 7E        LD      A,(HL)
DCC3 87        ADD     A,A
DCC4 87        ADD     A,A
DCC5 87        ADD     A,A
DCC6 87        ADD     A,A
DCC7 F5        PUSH    AF
DCC8 80        ADD     A,B
DCC9 47        LD      B,A
DCCA F5        PUSH    AF
DCCB E1        POP     HL
DCCC 7D        LD      A,L
DCCD E1        POP     HL
DCCE B5        OR      L
DCCF E601      AND     $01
DCD1 C9        RET

DCD2 0E0C      LD      C,$0C
DCD4 CD18D8    CALL    $D818
DCD7 2A43D4    LD      HL,($D443)
DCDA 112100    LD      DE,$0021
DCDD 19        ADD     HL,DE
DCDE E5        PUSH    HL
DCDF 72        LD      (HL),D
DCE0 23        INC     HL
DCE1 72        LD      (HL),D
DCE2 23        INC     HL
DCE3 72        LD      (HL),D
DCE4 CDF5D6    CALL    $D6F5
DCE7 CA0CDD    JP      Z,$DD0C
DCEA CD5ED6    CALL    $D65E
DCED 110F00    LD      DE,$000F
DCF0 CDA5DC    CALL    $DCA5
DCF3 E1        POP     HL
DCF4 E5        PUSH    HL
DCF5 5F        LD      E,A
DCF6 79        LD      A,C
DCF7 96        SUB     (HL)
DCF8 23        INC     HL
DCF9 78        LD      A,B
DCFA 9E        SBC     A,(HL)
DCFB 23        INC     HL
DCFC 7B        LD      A,E
DCFD 9E        SBC     A,(HL)
DCFE DA06DD    JP      C,$DD06
DD01 73        LD      (HL),E
DD02 2B        DEC     HL
DD03 70        LD      (HL),B
DD04 2B        DEC     HL
DD05 71        LD      (HL),C
DD06 CD2DD8    CALL    $D82D
DD09 C3E4DC    JP      $DCE4
DD0C E1        POP     HL
DD0D C9        RET

DD0E 2A43D4    LD      HL,($D443)
DD11 112000    LD      DE,$0020
DD14 CDA5DC    CALL    $DCA5
DD17 212100    LD      HL,$0021
DD1A 19        ADD     HL,DE
DD1B 71        LD      (HL),C
DD1C 23        INC     HL
DD1D 70        LD      (HL),B
DD1E 23        INC     HL
DD1F 77        LD      (HL),A
DD20 C9        RET
					; ########## LOGIN ###########
DD21 2AAFDE    LD      HL,($DEAF)	; READ LOG IN VECTOR
DD24 3A42D4    LD      A,($D442)	; CURDSK (current disk)
DD27 4F        LD      C,A		; C=disk to be selected
DD28 CDEAD5    CALL    $D5EA		; HL=HL/(2*C) - SHIFT (HL) RIGHT PER COUNT IN (C)
DD2B E5        PUSH    HL
DD2C EB        EX      DE,HL
DD2D CD59D4    CALL    $D459		; SETDSK (SET UP DISK PARAMETERS)
DD30 E1        POP     HL
DD31 CC47D4    CALL    Z,$D447		; call SELERR (DISK SELECT ERROR)
DD34 7D        LD      A,L		; LOG IN BIT IN LSB(A)
DD35 1F        RRA			; CHECK TO SEE IF ON MAP
DD36 D8        RET     C		; OK- DISK ALREADY LOGGED IN

DD37 2AAFDE    LD      HL,($DEAF)	; READ LOG IN VECTOR
DD3A 4D        LD      C,L
DD3B 44        LD      B,H		; BC=LOG IN VECTOR
DD3C CD0BD6    CALL    $D60B		; SET LOG IN VECTOR
DD3F 22AFDE    LD      ($DEAF),HL	; SAVE LOG IN VECTOR
DD42 C3A3D7    JP      $D7A3
					; ####### BDOS #0E (Select Disk) #######
DD45 3AD6DE    LD      A,($DED6)	; GET THE SELECTED DISK DRIVE NUMBER
DD48 2142D4    LD      HL,$D442		; addr of CURRENT DISK NUMBER
DD4B BE        CP      (HL)		; COMPARE TO CURRENT DISK NUMBER
DD4C C8        RET     Z		; RETURN IF NO CHANGE NEEDED
DD4D 77        LD      (HL),A		; ELSE SET (CURDSK) TO NEW DRIVE
DD4E C321DD    JP      $DD21		; AND GO LOG IT IN

					; ######## SETUP (SET UP DISK PARAMETERS) #######
DD51 3EFF	LD	A,$FF		; SET FLAG TO TELL BDOS2
DD53 32DEDE	LD	($DEDE),A	; THAT THE DISKS HAVE BEEN USED
DD56 2A43D4	LD	HL,($D443)	; HL = ENTRY PARAMETER
DD59 7E		LD	A,(HL)		; GET THE DISK NUMBER FROM FCB
DD5A E61F	AND	$1F		; DISK NUMBER TO BE IN RANGE OF 0 TO 1FH. I.E. DRIVES A THROUGH P
DD5C 3D		DEC	A
DD5D 32D6DE	LD	($DED6),A	; STORE IT FOR SELDSK
DD60 FE1E	CP	$1E
DD62 D275DD	JP	NC,$DD75	; SKIP OVER - ACCESSING LOGGED IN DISK
DD65 3A42D4	LD	A,($D442)	; SAVE CURRENT DISK NUMBER IN
DD68 32DFDE	LD	($DEDF),A	; LOGDSK FOR RESTORING ON EXIT
DD6B 7E		LD	A,(HL)		; GET DISK NUMBER FROM FCB AGAIN
DD6C 32E0DE	LD	($DEE0),A	; SAVE IT
					;	THE REASON FOR SETTING THE UPPER 3 BITS OF
					;	(FCB+12) WITH THE UPPER 3 BITS OF THE DRIVE
					;	NUMBER BROUGHT IN IN THE ENTRY PARAMETER IS
					;	NOT DOCUMENTED. THIS MAY BE SOME SORT OF
					;	PASSWORD SECURITY SYSTEM
DD6F E6E0	AND	$E0		; KEEP UPPER 3 BITS
DD71 77		LD	(HL),A		;  AND PUT THEM BACK IN FCB
DD72 CD45DD	CALL	$DD45		; SELECT DISK DRIVE
DD75 3A41D4	LD	A,($D441)	; GET THE USER NUMBER
DD78 2A43D4	LD	HL,($D443)	; GET THE ENTRY PARAMETER WHICH WAS ALREADY THERE (ANOTHER EXAMPLE OF REDUNDANCY)
DD7B B6		OR	(HL)		; COMBINE USER NUMBER W/ (FCB)
DD7C 77		LD	(HL),A		; MOVE INTO FIRST BYTE OF FCB
DD7D C9		RET

DD7E 3E22      LD      A,$22
DD80 C301D4    JP      $D401

DD83 210000    LD      HL,$0000		; ####### BDOS #0D (Reset Disk System) #######
DD86 22ADDE    LD      ($DEAD),HL	; CLEAR READ ONLY DISK STATUS WORD
DD89 22AFDE    LD      ($DEAF),HL	;  AND LOG IN VECTOR
DD8C AF        XOR     A		; set A=00 as current	[ 3E0n	  LD A,$0n	] Modification to allow this function
DD8D 3242D4    LD      ($D442),A	; disk to be selected	[ 3242D4  LD ($D442),A	] to set a default drive other than A:
DD90 218000    LD      HL,$0080		; DMA address...	[ 2F80    LD L,$80	] (DD8D) will hold the default drive
DD93 22B1DE    LD      ($DEB1),HL	; ...stored at (DEB1)
DD96 CDDAD6    CALL    $D6DA		; call BIOS SETDMA function
DD99 C321DD    JP      $DD21		; LOG-IN THE DISK & EXIT

DD9C CD72D6    CALL    $D672
DD9F CD51DD    CALL    $DD51
DDA2 C351D9    JP      $D951
DDA5 CD51DD    CALL    $DD51
DDA8 C3A2D9    JP      $D9A2

DDAB 0E00      LD      C,$00		; ####### BDOS #11 (Search for First) #######
DDAD EB        EX      DE,HL		; HL=FCB address
DDAE 7E        LD      A,(HL)		; A=first byte of FCB=drive no.
DDAF FE3F      CP      $3F		; check if it's a '?'
DDB1 CAC2DD    JP      Z,$DDC2
DDB4 CDA6D5    CALL    $D5A6
DDB7 7E        LD      A,(HL)
DDB8 FE3F      CP      $3F
DDBA C472D6    CALL    NZ,$D672
DDBD CD51DD    CALL    $DD51
DDC0 0E0F      LD      C,$0F
DDC2 CD18D8    CALL    $D818
DDC5 C3E9D6    JP      $D6E9
DDC8 2AD9DE    LD      HL,($DED9)
DDCB 2243D4    LD      ($D443),HL
DDCE CD51DD    CALL    $DD51
DDD1 CD2DD8    CALL    $D82D
DDD4 C3E9D6    JP      $D6E9
DDD7 CD51DD    CALL    $DD51
DDDA CD9CD8    CALL    $D89C
DDDD C301D8    JP      $D801
DDE0 CD51DD    CALL    $DD51	; call SETUP
DDE3 C3BCDA    JP      $DABC	; jump RDSEQ
DDE6 CD51DD    CALL    $DD51
DDE9 C3FEDA    JP      $DAFE
DDEC CD72D6    CALL    $D672
DDEF CD51DD    CALL    $DD51
DDF2 C324DA    JP      $DA24
DDF5 CD51DD    CALL    $DD51
DDF8 CD16D9    CALL    $D916
DDFB C301D8    JP      $D801
DDFE 2AAFDE    LD      HL,($DEAF)
DE01 C329DE    JP      $DE29
DE04 3A42D4    LD      A,($D442)
DE07 C301D4    JP      $D401

DE0A EB        EX      DE,HL		; ####### BDOS #1A (Set DMA Address) #######
DE0B 22B1DE    LD      ($DEB1),HL	; store DMA addr to ($DEB1)
DE0E C3DAD6    JP      $D6DA

DE11 2ABFDE    LD      HL,($DEBF)
DE14 C329DE    JP      $DE29
DE17 2AADDE    LD      HL,($DEAD)
DE1A C329DE    JP      $DE29
DE1D CD51DD    CALL    $DD51
DE20 CD3BD9    CALL    $D93B
DE23 C301D8    JP      $D801
DE26 2ABBDE    LD      HL,($DEBB)
DE29 2245D4    LD      ($D445),HL
DE2C C9        RET

DE2D 3AD6DE    LD      A,($DED6)
DE30 FEFF      CP      $FF
DE32 C23BDE    JP      NZ,$DE3B
DE35 3A41D4    LD      A,($D441)
DE38 C301D4    JP      $D401
DE3B E61F      AND     $1F
DE3D 3241D4    LD      ($D441),A
DE40 C9        RET

DE41 CD51DD    CALL    $DD51
DE44 C393DC    JP      $DC93
DE47 CD51DD    CALL    $DD51
DE4A C39CDC    JP      $DC9C
DE4D CD51DD    CALL    $DD51
DE50 C3D2DC    JP      $DCD2
DE53 2A43D4    LD      HL,($D443)
DE56 7D        LD      A,L
DE57 2F        CPL
DE58 5F        LD      E,A
DE59 7C        LD      A,H
DE5A 2F        CPL
DE5B 2AAFDE    LD      HL,($DEAF)
DE5E A4        AND     H
DE5F 57        LD      D,A
DE60 7D        LD      A,L
DE61 A3        AND     E
DE62 5F        LD      E,A
DE63 2AADDE    LD      HL,($DEAD)
DE66 EB        EX      DE,HL
DE67 22AFDE    LD      ($DEAF),HL
DE6A 7D        LD      A,L
DE6B A3        AND     E
DE6C 6F        LD      L,A
DE6D 7C        LD      A,H
DE6E A2        AND     D
DE6F 67        LD      H,A
DE70 22ADDE    LD      ($DEAD),HL
DE73 C9        RET

DE74 3ADEDE    LD      A,($DEDE)	; BDOS EXIT POINT ADDRESS
DE77 B7        OR      A
DE78 CA91DE    JP      Z,$DE91
DE7B 2A43D4    LD      HL,($D443)
DE7E 3600      LD      (HL),$00
DE80 3AE0DE    LD      A,($DEE0)
DE83 B7        OR      A
DE84 CA91DE    JP      Z,$DE91
DE87 77        LD      (HL),A
DE88 3ADFDE    LD      A,($DEDF)
DE8B 32D6DE    LD      ($DED6),A
DE8E CD45DD    CALL    $DD45
DE91 2A0FD4    LD      HL,($D40F)
DE94 F9        LD      SP,HL
DE95 2A45D4    LD      HL,($D445)
DE98 7D        LD      A,L
DE99 44        LD      B,H
DE9A C9        RET

DE9B CD51DD    CALL    $DD51
DE9E 3E02      LD      A,$02
DEA0 32D5DE    LD      ($DED5),A
DEA3 0E00      LD      C,$00
DEA5 CD07DC    CALL    $DC07
DEA8 CC03DB    CALL    Z,$DB03
DEAB C9        RET

DEAC E5		DEFB	$E5	; DUMMY FCB- USED FOR SEARCHING FOR UNUSED DIRECTORY SLOTS
DEAD 0000	DEFW	$0000	; READ ONLY DISK STATUS WORD
DEAF 0000	DEFW	$0000	; LOG IN VECTOR
DEB1 8000	DEFW	$0080	; CURRENT DMA ADDRESS. INTIALLY = DDMA
DEB3 0000	DEFW	$0000
DEB5 0000	DEFW	$0000
DEB7 0000	DEFW	$0000
DEB9 0000	DEFW	$0000	; DIRECTORY BUFFER POINTER
DEBB 0000	DEFW	$0000	; DISK PARAMETER BLOCK POINTER
DEBD 0000	DEFW	$0000	; DIRECTORY CHECKSUM BLOCK POINTER
DEBF 0000	DEFW	$0000	; ALLOCATION BIT MAP POINTER

				; ######### DISK PARAMETER BLOCK
				; ######### Moved into place when disk is logged in

DEC1 0000	DEFW	$0000	; SECTORS PER TRACK
DEC3 00		DEFB	$00	; BLOCK SHIFT FACTOR
DEC4 00		DEFB	$00	; DISK BLOCK MASK
DEC5 00		DEFB	$00	; NULL BLOCK MASK
DEC6 0000	DEFW	$0000	; DISK SIZE (# OF 1K BLOCKS -1)
DEC8 0000	DEFW	$0000	; MAX NUMBER OF ENTRIES IN DIRECTORY
DECA 0000	DEFW	$0000	; SIZE OF ALLOCATION BLOCK
DECC 0000	DEFW	$0000	; NUMBER OF DIRECTORY SECTORS TO BE CHECKED
DECE 0000	DEFW	$0000	; DIRECTORY TRACK NUMBER

DED0 0000	DEFW	$0000	; VECTOR TO SECTOR TRANSLATION TABLE
DED2 00		DEFB	$00	; MAKE-FILE FLAG
DED3 00		DEFB	$00	; READ/WRITE FLAG
DED4 00		DEFB	$00	; POINTER SET TO 0FFH BY SERCHF AND
				; CLEARED TO 00 WHEN A FILE NAME MATCH
				; HAS BEEN MADE
DED5 00		DEFB	$00	; SEQUENTIAL/RANDOM I/O FLAG
				; SET 01 FOR SEQUENTIAL READ/WRITE
				; SET 00 FOR RANDOM READ/WRITE
				; SET 02 FOR UNDOCUMENTED COMMAND #40
DED6 00		DEFB	$00	; SET TO (E) ON ENTRY TO BDOS, THEN USED TO STORE DISK NUMBER
DED7 00		DEFB	$00	; TEMPORARY STORAGE FOR OFFSET TO BLOCK NUMBER IN DIRECTORY DURING WRSEQ.
				; POINTS TO BYTE(S) THAT CONTAIN THE CURRENT BLOCK NUMBER.
				; WHEN THE 8TH SECTOR OF THE BLOCK HAS BEEN WRITTEN,
				; BLKOFF IS INCREMENTED AND A NEW BLOCK SELECTED.
DED8 00		DEFB	$00	; SEARCH COUNTER-NUMBER OF BYTES TO BE COMPARED BETWEEN THE FILE CONTROL BLOCK
				; AND THE DIRECTORY ENTRY. THE COUNT IS SET ON ENTRY VIA SERCHF & PICKED UP FOR USE BY SERCHN
DED9 0000	DEFW	$0000	; SEARCH FCB POINTER, SET BY SERCHF/SERCHN
DEDB 0000	DEFW	$0000	; (NOT USED)
DEDD 00		DEFB	$00	; 8" SD: 0FFH, LARGE CAP DISK: 00H
DEDE 00		DEFB	$00	; DISK SETUP FLAG (SETUPF)
DEDF 00		DEFB	$00	; LOGDSK (disk on entry to bdos)
DEE0 00		DEFB	$00	; DISK NUMBER (DISKNO) (disk named in fcb)
DEE1 00		DEFB	$00	; FILE RECORD COUNTER: FCB + 15
DEE2 00		DEFB	$00	; FILE EXTENT COUNTER: FCB + 12
DEE3 0000	DEFW	$0000	; CURRENT RECORD:: FCB + 32
DEE5 0000	DEFW	$0000	; SECTOR COUNTER #1
DEE7 0000	DEFW	$0000	; SECTOR COUNTER #2
DEE9 00		DEFB	$00	; DIRECTORY OFFSET
DEEA 0000	DEFW	$0000	; BLOCK COUNTER #1
DEEC 0000	DEFW	$0000	; BLOCK COUNTER #2

DEEE 00        DEFB    $00
DEEF 00        DEFB    $00
DEF0 00        DEFB    $00
DEF1 00        DEFB    $00
DEF2 00        DEFB    $00
DEF3 00        DEFB    $00
DEF4 00        DEFB    $00
DEF5 00        DEFB    $00
DEF6 00        DEFB    $00
DEF7 00        DEFB    $00
DEF8 00        DEFB    $00
DEF9 00        DEFB    $00
DEFA 00        DEFB    $00
DEFB 00        DEFB    $00
DEFC 00        DEFB    $00
DEFD 00        DEFB    $00
DEFE 00        DEFB    $00
DEFF 00        DEFB    $00